<template>
	<view class="container">
		<view class="content">
			<header-view></header-view>
			<view class="title">消息通知</view>
			<view class="list" v-if="list!=0">
				<view class="item" v-for="item in list">
					<!-- 提现 -->
					<!-- 					<view class="item_box flex" v-if="item%2==0">
						<view class="icon flex_center bg_down">
							<uni-icons custom-prefix="iconfont" type="icon-shangchuan" color="#fff" size="20"
								style="font-weight: bold;"></uni-icons>
						</view>
						<view class="detail font_title">
							<view class="top flex">
								<view class="status flex_center bg_down">提现</view>
								<view class="number ">100</view>
							</view>
							<view class="time">2023-12-12 17:35:25</view>
						</view>
						<view class="item_icon flex_center" @tap="clear(item)">
							<uni-icons custom-prefix="iconfont" type="icon-duigou" size="18" color="#0065ff"
								style="font-weight: 600;"></uni-icons>
						</view>
					</view> -->
					<!-- 充值 -->
					<view class="item_box flex">
						<view class="icon flex_center bg_up">
							<!-- <uni-icons custom-prefix="iconfont" type="icon-xiazai" color="#fff" size="20"
								style="font-weight: bold;"></uni-icons> -->
							<uni-icons custom-prefix="iconfont" type="icon-xinxifill" size="20"
								color="#fff"></uni-icons>
						</view>
						<view class="detail">
							<view class="top flex">
								<view class="status flex_center bg_up">{{item.name}}</view>
								<view class="number font_title">{{item.content}}</view>
							</view>
							<view class="time">{{item.time_str}}</view>
						</view>
						<view class="item_icon flex_center" @tap="clear(item)">
							<uni-icons custom-prefix="iconfont" type="icon-duigou" size="18" color="#0065ff"
								style="font-weight: 600;"></uni-icons>
						</view>
					</view>
				</view>
			</view>
			<view class="no_list flex_center" v-else>
				<image src="../../../static/img/no_list.png" mode="widthFix" style="width: 420rpx;"></image>
			</view>
		</view>
	</view>
</template>

<script>
	import headerView from "@/components/headerView.vue"
	import {
		noticeListApi
	} from '@/api/api.js'
	import {
		data
	} from "../../../uni_modules/uview-ui/libs/mixin/mixin"
	export default {
		components: {
			headerView
		},
		data() {
			return {
				list: []
			}
		},
		onLoad() {
			this.getNoticeList()
		},
		methods: {
			// 获取消息公告列表
			getNoticeList() {
				noticeListApi().then(res => {
					console.log(res.data.data)
					this.list = res.data.data.data
				})
			},
			clear(item) {
				console.log(item, "<<<<<<<<<选中的消息");
				uni.$u.toast("已确认");

				// 假设 item 是要删除的消息对象
				const index = this.list.indexOf(item);

				if (index !== -1) {
					// 使用 splice 删除指定索引的元素
					this.list.splice(index, 1);
				}
			}

		}
	}
</script>

<style lang="scss" scoped>
	.content {
		position: relative;

		.title {
			padding-top: 60rpx;
			font-size: 30px;
			font-weight: 500;
			font-family: PM;
			line-height: 92rpx;
		}

		.list {
			margin-top: 50rpx;

			.item_box {
				column-gap: 30rpx;
				margin: 30rpx 0;

				.icon {
					width: 86rpx;
					height: 86rpx;
					border-radius: 20rpx;
				}

				.detail {
					flex: 1;

					.top {
						.status {
							padding: 10rpx;
							margin-right: 10rpx;
							border-radius: 6rpx;
							font-size: 22rpx;
							height: 42rpx;
						}

						.number {
							font-size: 36rpx;
						}
					}

					.time {
						font-size: 24rpx;
						opacity: .6;
					}
				}

				.item_icon {
					padding: 14rpx 26rpx;
					border-radius: 20rpx;
					background-color: rgba(0, 101, 255, .1);
				}
			}
		}
	}
</style>